package sury.biz.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import sury.biz.service.RoleMenuService;
import sury.biz.service.RoleService;
import sury.dal.entity.AdminRoleEntity;
import sury.dal.entity.RoleEntity;
import sury.dal.entity.RoleMenuEntity;
import sury.dal.mapper.AdminRoleMapper;
import sury.dal.mapper.RoleMapper;
import sury.dal.mapper.RoleMenuMapper;

import java.util.List;
import java.util.stream.Collectors;

@Service
@Slf4j
public class RoleServiceImpl extends ServiceImpl<RoleMapper, RoleEntity> implements RoleService {
    @Autowired
    private RoleMenuService roleMenuService;

    @Override
    public List<Long> getMenuIdsByRoleId(Long roleId) {
        List<RoleMenuEntity> roleMenus = roleMenuService.list(new QueryWrapper<RoleMenuEntity>()
                .select("menu_id")
                .eq("role_id", roleId));
        // 提取menu_id列表
        return roleMenus.stream().map(RoleMenuEntity::getMenuId).collect(Collectors.toList());
    }
}
